local tianmengzhijing = fk.CreateSkill {
  name = "tianmengzhijing",
}

-- 加载技能的翻译表，用于显示技能的名称、描述等信息
Fk:loadTranslationTable{
  -- 技能的名称
  ["tianmengzhijing"] = "甜梦之镜",
  -- 技能的详细描述
  [":tianmengzhijing"] = "回合开始时，你可以复活一名已死亡的梦之队势力角色。",
  -- 技能的简略描述
  ["#tianmengzhijing"] = "甜梦之镜：令一名已死亡的梦之队势力角色。",


}

-- 为技能添加一个主动效果
tianmengzhijing:addEffect(fk.EventPhaseStart, {
  -- 判断技能是否可以使用的函数
  can_use = function(self, player)
    -- 检查玩家在整个游戏历史中使用该技能的次数是否为 0
   return target == player and player:hasSkill(self.name) and player.phase == Player.Start
    and  #table.map(table.filter(player.room.players, function(p) return p.kingdom=="dream" and p.dead end), function(p) return p.general end) > 0
    and player:usedSkillTimes("tianmengzhijing",Player.HistoryPhase)==0
  end,
  on_use = function(self, target,player,room, effect)
    local room = player.room
    local targets = table.map(table.filter(room.players, function(p) return p.kingdom=="dream" and p.dead end), function(p) return p.general end)
      if #targets > 0 then
        local target = room:askForChoice(player, targets, self.name, "#tianmengzhijing")
        if #target>0  then
          for _, p in ipairs(room.players) do
            if p.general == target then
              room:revivePlayer(p, true)
              break
            end
          end
        end
      end
    
    
  end,
})



-- 返回创建的技能
return tianmengzhijing